<?php
class ControllerPaymentFreeCheckout extends AdminController {

	public function index() {

		if ($this->request->isPost() && $this->validate()) {
			M('setting/setting');
			$this->model_setting_setting->editSetting('free_checkout', $this->request->post);

			$this->session->set_flashdata('success', $this->_['text_success']);
			$this->redirect(UA('extension/payment'));
		}

		$this->document->setTitle($this->_['heading_title']);
  		$this->data['breadcrumbs'] = array();

   		$this->data['breadcrumbs'][] = array(
       		'text'      => $this->_['text_home'],
			'href'      =>  UA('common/home'),
      		'separator' => false
   		);

   		$this->data['breadcrumbs'][] = array(
       		'text'      => $this->_['text_payment'],
			'href'      => UA('extension/payment'),
      		'separator' => ' :: '
   		);

   		$this->data['breadcrumbs'][] = array(
       		'text'      => $this->_['heading_title'],
			'href'      => UA('payment/free_checkout'),
      		'separator' => ' :: '
   		);


		M('localisation/order_status');
		$this->data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();

		$this->display('payment/free_checkout.tpl');
	}

	protected function validate() {
		if (!$this->hasMP()) {
			$this->setMessage('error_warning', $this->_['error_permission']);
			return false;
		}

		return true;
	}
}
?>